--INV_ADMINPASS = "klapaucious" -- password for admin panel so you can easily hand control to someone else

function inv_showadminspare( ply )
	ply:ConCommand("player_adminpanel")
end
hook.Add("ShowSpare1", "inv_showadminspare", inv_showadminspare)

function inv_resetstats( commander, command, arguments )
	if command == nil and arguments == nil then
		commander:SetStats(INV_STARTLEVEL, INV_STARTXP, INV_STARTPOINTS, INV_STARTMONEY, INV_STARTWEAPONSPEED, INV_STARTWEAPONDAMAGE, INV_STARTSPEED, INV_STARTCLIPSIZE, INV_STARTMAXHEALTH, INV_STARTDAMAGETAKEN, INV_STARTBUYABLES, INV_STARTJUMP, INV_STARTSPREAD)
	end

	if( commander:IsAdmin() == false)then
		SendMessageToPlayerChat(commander, "You are not an admin...")
		return
	end
	
	for _, v in pairs(player.GetAll()) do
		if( v:Nick() == arguments[1] ) then
			v:SetStats(INV_STARTLEVEL, INV_STARTXP, INV_STARTPOINTS, INV_STARTMONEY, INV_STARTWEAPONSPEED, INV_STARTWEAPONDAMAGE, INV_STARTSPEED, INV_STARTCLIPSIZE, INV_STARTMAXHEALTH, INV_STARTDAMAGETAKEN, INV_STARTBUYABLES, INV_STARTJUMP, INV_STARTSPREAD)
			DoPlayerUpgrades(v)
			GivePlayerOwnedStuff(v)
			SendMessageToPlayerChat(v, "Your stats were reset by an admin")
		end
	end
end
concommand.Add( "inv_resetstats", inv_resetstats )

function inv_killturrets( commander, command, arguments )
	if( commander:IsAdmin() == false)then
		SendMessageToPlayerChat(commander, "You are not an admin...")
		return
	end
	for k, v in pairs(ents.FindByClass("npc_turret_floor")) do
		v:remove()
	end
end
concommand.Add( "inv_killturrets", inv_killturrets )

function inv_givemoney( commander, command, arguments )
	if( commander:IsAdmin() == false)then
		SendMessageToPlayerChat(commander, "You are not an admin...")
		return
	end
	
	for _, v in pairs(player.GetAll()) do
		if( v:Nick() == arguments[1] ) then
			v:AddMoney(arguments[2])
			SendMessageToPlayerChat(v, "You were given "  .. INV_MONEYPREFIX .. tostring(arguments[2]) .. " by an admin")
		end
	end
end
concommand.Add( "inv_givemoney", inv_givemoney )

function inv_givepoints( commander, command, arguments )
	if( commander:IsAdmin() == false)then
		SendMessageToPlayerChat(commander, "You are not an admin...")
		return
	end
	
	for _, v in pairs(player.GetAll()) do
		if( v:Nick() == arguments[1] ) then
			v:AddStatPoints(arguments[2])
			SendMessageToPlayerChat(v, "You were given " .. tostring(arguments[2]) .. " points by an admin")
		end
	end
end
concommand.Add( "inv_givepoints", inv_givepoints )

function inv_givestat( commander, command, arguments )
	if( commander:IsAdmin() == false)then
		SendMessageToPlayerChat(commander, "You are not an admin...")
		return
	end
	
	for _, v in pairs(player.GetAll()) do
		if( v:Nick() == arguments[1] ) then
			-- Populate function list
			local stat = arguments[2]
			
			if stat == "weaponspeed" then v:AddWeaponSpeed(arguments[3]) end
			if stat == "weapondamage" then v:AddWeaponDamage(arguments[3]) end
			if stat == "speed" then v:AddSpeed(arguments[3]) end
			if stat == "clipsize" then v:AddClipSize(arguments[3]) end
			if stat == "maxhealth" then v:AddMaxHealth(arguments[3]) end
			if stat == "damagetaken" then v:AddDamageTaken(arguments[3]) end
			if stat == "spread" then v:AddSpread(arguments[3]) end
			if stat == "jump" then v:AddJump(arguments[3]) end
		end
	end
end
concommand.Add( "inv_givestat", inv_givestat )

function inv_nextwave( commander, command, arguments )
	if( commander:IsAdmin() == false)then
		SendMessageToPlayerChat(commander, "You are not an admin...")
		return
	end
	NextWave()
end
concommand.Add( "inv_nextwave", inv_nextwave )